/******************************************************************************
//             INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//    Copyright(c) 2001 Intel Corporation. All Rights Reserved.
//
//  VSS: 
//     $Workfile: $
//     $Revision: $
//     $Date:     $
//     $Archive:  $
//
//  Description:
//      Basic definitions for Intel MultiMedia Processing
//
//  History:
//     Date        Author        Changes
//     2001/9/11   Jerry Hu       Created  (Version 0.1)
//
********************************************************************************/

#ifndef _IMPBASE_H
#define _IMPBASE_H

#include "ippdefs.h"

#ifdef __cplusplus
extern "C" {
#endif

/*---------------------------------------------------------------------------*/

/*
//  Image Modes
*/
#define IIP_CM_NONE            0x0 
#define IIP_CM_NONINTERLEAVE   0x80000000
#define IIP_CM_GRAY            0x00000001
#define IIP_CM_BGR             0x00000002
#define IIP_CM_BGRA            0x00000004
#define IIP_CM_BGR555          0x00000008
#define IIP_CM_BGR565          0x00000010
#define IIP_CM_RGB             0x00000020
#define IIP_CM_ARGB            0x00000040
#define IIP_CM_RGB555          0x00000080
#define IIP_CM_RGB565          0x00000100

/*
//  Subsampling Modes
*/
#define IIP_SM_NONE            0x00000000
#define IIP_SM_422             0x00000001
#define IIP_SM_411             0x00000002
#define IIP_SM_ARBITRARY       0x80000000

/*
//  Helper
*/
#define  IIP_ALIGN_32B(adr)    (((((unsigned int)(adr))+31)&(~31)))
#define  IIP_WIDTHBYTES_4B(x)  ((((x)+31)&(~31))>>3)    

#define  IIP_MAX(a, b)         ((a)>(b)?(a):(b))
#define  IIP_MIN(a, b)         ((a)<(b)?(a):(b))

#define  IIP_DIV_CEIL(a, b)    ( ((a)+(b)-1)/(b) ) 
#define  IIP_DIV_FLOOR(a, b)   ( (a)/(b) ) 
#define  IIP_DIVP2_CEIL(a, b)  ( ((a)+(1<<(b))-1)>>(b) ) 
#define  IIP_DIVP2_FLOOR(a, b) ( (a)>>(b) ) 
#define  IIP_CLIP_IPP8U(x)     ((Ipp8u)( (0>x)?0:(x>255?255:x) ))

#define  IIP_READ_BI_INT16(ptr)   ((Ipp16u)(ptr)[1]|((Ipp16u)(ptr)[0]<<8))
#define  IIP_READ_BI_INT32(ptr)   ( (((Ipp32u)(ptr)[3])&0xff)|((((Ipp32u)(ptr)[2])<<8)&0xff00)|    \
                                 ((((Ipp32u)(ptr)[1])<<16)&0xff0000)|((((Ipp32u)(ptr)[0])<<24)&0xff000000) )

#define  IIP_READ_LI_INT16(ptr)   ((Ipp16u)(ptr)[0]|((Ipp16u)(ptr)[1]<<8))
#define  IIP_READ_LI_INT32(ptr)   ( (((Ipp32u)(ptr)[0])&0xff)|((((Ipp32u)(ptr)[1])<<8)&0xff00)|    \
                                 ((((Ipp32u)(ptr)[2])<<16)&0xff0000)|((((Ipp32u)(ptr)[3])<<24)&0xff000000) )

#define  IIP_WRITE_BI_INT32(ptr, value)	          \
    {                                             \
        ptr[0] = (Ipp8u)(((value) >> 24) & 0xff); \
        ptr[1] = (Ipp8u)(((value) >> 16) & 0xff); \
        ptr[2] = (Ipp8u)(((value) >> 8) & 0xff);  \
        ptr[3] = (Ipp8u)((value) & 0xff);         \
    }

#define IIP_WRITE_BI_INT16(ptr, value)            \
    {                                             \
        ptr[0] = (Ipp8u)(((value) >> 8) & 0xff);  \
        ptr[1] = (Ipp8u)((value) & 0xff);         \
    }

#define  IIP_WRITE_LI_INT32(ptr, value)	          \
    {                                             \
        ptr[3] = (Ipp8u)(((value) >> 24) & 0xff); \
        ptr[2] = (Ipp8u)(((value) >> 16) & 0xff); \
        ptr[1] = (Ipp8u)(((value) >> 8) & 0xff);  \
        ptr[0] = (Ipp8u)((value) & 0xff);         \
    }

#define IIP_WRITE_LI_INT16(ptr, value)            \
    {                                             \
        ptr[1] = (Ipp8u)(((value) >> 8) & 0xff);  \
        ptr[0] = (Ipp8u)((value) & 0xff);         \
    }

/*---------------------------------------------------------------------------*/
typedef struct _IIPIMAGESPEC
{
    Ipp32s nWidth;
    Ipp32s nHeight;
    Ipp32s nPrecision;
    Ipp32s nBitsPerpixel;
    Ipp32s nNumComponent;
    Ipp32s nColorMode;
    Ipp32s nSamplingMode;
    Ipp32s nDensityUnit;
    Ipp32s nXDensity;
    Ipp32s nYDensity;
} IIPIMAGESPEC;

/*---------------------------------------------------------------------------*/
#define IWP_CM_NONE 0
#define IWP_CM_PCM  1
#define IWP_CM_G726 2
#define IWP_CM_G728 3
#define IWP_CM_G729 4

typedef struct _IWPWAVESPEC
{
     Ipp32u nCodeMode;      
     Ipp32u nChannels;       
     Ipp32u nSamplesPerSec;  
     Ipp32u nAvgBytesPerSec; 
     Ipp32u nBlockAlign;     
     Ipp32u nBitsPerSample;  
} IWPWAVESPEC;

/*---------------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif

/* EOF */
